#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
   @Author: 叶建伟
   @Email: yejw46507@hundsun.com
   @Time: 2023/5/11 20:03
   @File: FileOerate.py
"""
import os
#from CommonScripts.Logs import logger
import re

from BladeFerm.Lib.Common import logger


def getFilePath(fileName, path=f'E:\\UI自动化\\Project\\金融反洗钱项目\\web应用\\data'):
    """
    查找路径
    :param fileName:
    :param path:
    :return:
    """
    logger.info(f"getFilePath fileName: {fileName},path: {path}")
    for root, dirs, files in os.walk(path):
        logger.debug(f"root, dirs, files: {root, dirs, files}")
        for file in files:
            filepath = os.path.join(root, file)
            if re.search(fileName, filepath):
                logger.info(f'文件路径：{filepath}')
                return filepath
    return None


def getFilesByPath(path=f'E:\\UI自动化\\Project\\金融反洗钱项目\\web应用\\data'):
    """
    查找路径下的所有文件
    :param path:
    :return:
    """
    result = list()
    logger.info(f"fund file on path : {path}")
    for root, dirs, files in os.walk(path):
        logger.debug(f"root, dirs, files: {root, dirs, files}")
        for file in files:
            filepath = os.path.join(root, file)
            result.append(filepath)
    return result


if __name__ == '__main__':
    root_path = "E:\AutoTest\Project\金融反洗钱项目\web应用\DataTest\\tabledata"
    getFilePath(fileName="taaml_n_confirm.json", path=root_path)
    # 交易流水查询-账户申请确认.sql
    # 交易流水查询-账户申请确认.sql